package com.example.employ.controller;

import com.example.employ.common.convention.result.Result;
import com.example.employ.common.convention.result.Results;
import com.example.employ.dto.request.ResumeRemoveDTO;
import com.example.employ.dto.request.ResumeSaveReqDTO;
import com.example.employ.dto.request.ResumeUpdateReqDTO;
import com.example.employ.dto.response.ResumeDetailRespDTO;
import com.example.employ.service.ResumeService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 简历管理
 */
@RestController()
@RequiredArgsConstructor
public class ResumeController {

    private final ResumeService resumeService;

    /**
     * 新增简历
     */
    @PostMapping("/api/recruit/v1/resume")
    public Result<Void> saveResume(@RequestBody ResumeSaveReqDTO requestParam){
        resumeService.saveResume(requestParam);
        return Results.success();
    }

    /**
     * 删除简历
     */
    @DeleteMapping("/api/recruit/v1/resume/remove")
    public Result<Void> saveResume(@RequestParam("userId") Long userId){
        resumeService.removeResume(userId);
        return Results.success();
    }

    /**
     * 获取简历信息
     */
    @GetMapping("/api/recruit/v1/resume/{userId}")
    public Result<ResumeDetailRespDTO> detail(@PathVariable("userId") Long userId){
        return Results.success(resumeService.detail(userId));
    }

    /**
     * 修改简历信息
     */
    @PutMapping("/api/recruit/v1/resume/update")
    public Result<Void> updateResume(@RequestBody ResumeUpdateReqDTO requestParam){
        resumeService.updateResume(requestParam);
        return Results.success();
    }
}
